var e = require("./risk/risk"),
  i = require("../buildConfig.js").BuildConfig,
  r = require("./utils/networkUtil.js"),
  t = require("./utils/util.js"),
  n = require("./dfp/dfp"),
  u = require("./device/device"),
  l = require("./utils/murmurhash2"),
  a = require("./utils/xxtea_new"),
  s = null,
  o = null,
  c = null;
function k(i) {
  var r = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];
  n.getDfpTicket(function (t) {
    e.getDeviceToken(t.data.ticketID, o, c, i, r);
  });
}
module.exports = {
  init: function (u, k, p) {
    (s = u), (o = k);
    var d = k.apiUrl,
      f = k.riskUrl;
    (o.apiUrl = a.decrypt(i.apiUrl, "turing")),
      (o.riskUrl = a.decrypt(i.riskUrl, "turing")),
      (o.salt = l.hash32("saas_" + o.channel + "_", 0).toString(16)),
      (k.extra_network && k.extra_network.request) || (c = r.defaultNetwork),
      t.isEmpty(d) ||
        ((o.apiUrl = d + "/data/1938/forward"),
        (o.riskUrl = d + "/data/1941/forward"),
        (o.salt = l.hash32("private_" + o.channel + "_", 0).toString(16))),
      t.isEmpty(d) || t.isEmpty(f) || ((o.apiUrl = d), (o.riskUrl = f)),
      (o.requireType = i.requireType),
      e.initRisk(o),
      n.initDfp(c, s, o, p);
  },
  getTicket: function (e) {
    try {
      n.getDfpTicket(e);
    } catch (i) {
      e({ ret: -1003, data: { ticketID: "" } });
    }
  },
  getDeviceToken: function (e) {
    k(e, !1);
  },
  getDeviceTokenV2: k,
  getSDKInfo: function () {
    return {
      version: i.sdkVersion,
      lc: i.lc,
      buildNo: i.buildNo,
      requireType: i.requireType,
    };
  },
  getDeviceInfo: function () {
    return u.getDeviceInfo();
  },
};
